package com.linkhub.oms.admin.modules.oss.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.linkhub.oms.admin.modules.oss.domain.param.PutObjectParam;
import com.linkhub.oms.admin.modules.oss.domain.vo.PutObjectResultVO;
import com.linkhub.oms.admin.modules.oss.service.AliyunOSSBizService;
import com.linkhub.oms.common.response.DataResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @Description: AliyunOSSController
 * @Author: echo
 * @Date: 2024/5/8 20:11
 * @Version: 1.0
 */
@Slf4j
@RestController
@Api(tags = {"阿里云oss模块"})
@RequestMapping("/oss")
@SaCheckLogin
public class AliyunOSSController {


    @Resource
    private AliyunOSSBizService ossBizService;

    @PostMapping("/upload")
    @ApiOperation(value = "简单文件上传接口")
    public DataResponse<PutObjectResultVO> save(@Valid PutObjectParam putObjectParam,
                                                @RequestParam(value = "file") MultipartFile file) {
        putObjectParam.setObject(file);
        return DataResponse.success(ossBizService.upload(putObjectParam));
    }
}
